<?php

function __autoload($class_name) 
{
    require_once "$class_name.class.php";
}

$parrainage=new SplObjectStorage();
$p2=$p=new Profil("profil_0"); 
for ($i=1;$i<3;$i++) {
	$p=$p2;
	$p2=new Profil("profil_$i");
	$parrainage[$p]=$p2;
}


echo "\n\nNb element: ".count($parrainage)."\n";
echo "Recherche avec index en objet: \n";
print_r($parrainage[$p]);

echo "Parcours complet des parrainages: \n";

$parrainage->rewind();
while($parrainage->valid()) {
    $index  = $parrainage->key();
    $object = $parrainage->current(); 
	$data	= $parrainage->getInfo();
	echo "######################################\n";
	echo "Index: $index\n";
	echo "Valeur: $object\n";
	echo "Info: $data\n";
	$parrainage->next();
}

echo "\n######################################\n";
print_r($parrainage);
echo "######################################\n";
?>
